#include "stdafx.h"
#include "Vector3df.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

Vector3df operator+(const Vector3df& v1, const Vector3df& v2)
{
	return Vector3df(
		v1.m_coords[0] + v2.m_coords[0],
		v1.m_coords[1] + v2.m_coords[1],
		v1.m_coords[2] + v2.m_coords[2]);
}

Vector3df operator-(const Vector3df& v1, const Vector3df& v2)
{
	return Vector3df(
		v1.m_coords[0] - v2.m_coords[0],
		v1.m_coords[1] - v2.m_coords[1],
		v1.m_coords[2] - v2.m_coords[2]);
}

Vector3df operator-(const Vector3df& v)
{
	return Vector3df(
		-v.m_coords[0],
		-v.m_coords[1],
		-v.m_coords[2]);
}

Vector3df operator*(const Vector3df& v1, const Vector3df& v2)
{
	return Vector3df(
		v1.m_coords[0] * v2.m_coords[0],
		v1.m_coords[1] * v2.m_coords[1],
		v1.m_coords[2] * v2.m_coords[2]);
}

Vector3df operator*(const Vector3df& v, const float& s)
{
	return Vector3df(
		v.m_coords[0] * s,
		v.m_coords[1] * s,
		v.m_coords[2] * s);
}

Vector3df operator*(const float& s, const Vector3df& v)
{
	return v * s;
}

Vector3df operator/(const Vector3df& v, const float& s)
{
	if(s == 0) return Vector3df(0.0f, 0.0f, 0.0f);
	return v * (1.0f / s);
}

float Vector3df::distance(const Vector3df& v) const
{
	return (v - *this).length();
}